﻿using Models.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using yymbBLL;

namespace WebApp_WB.Controllers
{
    [Authorize]
    public class OtherController : Controller
    {
        private OtherManger db = new OtherManger();
        private yymbDBEntities _efdb = new yymbDBEntities();
        private LikeManger lk = new LikeManger();
        // GET: Other
        public ActionResult OtherIndex(int id)
        {
            int Userid = Convert.ToInt32(Session["UserID"].ToString());
            ViewBag.like = lk.Like(id);
            ViewBag.popu = lk.popu(id);
            ViewBag.guan = lk.Foll(id, Userid);
            ViewBag.Follow = db.GetUserFollow(id);
            ViewBag.atte = db.Oth_use_atte(id);
            ViewBag.fans = db.Oth_use_fans(id);
            ViewBag.SumWB = db.SumWB(id);

            ViewBag.Information = _efdb.Information.Find(id);//基本信息       
            ViewBag.User = _efdb.User.Find(id);//注册信息
            ViewBag.Education = _efdb.Education.Where(e => e.UserID == id).FirstOrDefault();//学历信息
            
            ViewBag.Occupation = _efdb.Occupation.Where(o => o.UserID == id).FirstOrDefault();//职业信息

            ViewBag.Personality = _efdb.Personality_tag.Where(p => p.UserID == id);//个性标签
            if (ViewBag.Personality==null)
            {
                ViewBag.Personality = new Personality_tag();
            }

            return View(db.Oth_use_Info(id));
        }
        /// <summary>
        /// 点赞的方法
        /// </summary>
        /// <param name="Mbid"></param>
        /// <returns></returns>
        public int Follow(int Mbid)//Mid 当前页面的用户ID   uid登录用户的id
        {
            LikeManger db = new LikeManger();
           int Userid = Convert.ToInt32(Session["UserID"].ToString());
            return db.Follow(Mbid, Userid);
        }
    }
}